#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(double dx = 0.0, double dy = 0.0)
    : _dx(dx)
    , _dy(dy)
    {
        cout << "Point(double = 0.0, double = 0.0)" << endl;
    }

    //普通函数与成员函数都可以设置为模板形式
    template <typename T = double>
    T func()
    {
        return (T)_dx;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }
private:
    double _dx;
    double _dy;
};

void test()
{
    Point pt(1.1, 2.2);
    cout << "pt.func() = " << pt.func<int>() << endl;//
    cout << "pt.func() = " << pt.func() << endl;//

}

int main(int argc, char **argv)
{
    test();
    return 0;
}

